Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proteomics repository retriever #753

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
a6b1639
correct Within calculation
Nov 18, 2021
fa4da8b
update unit tests
Nov 18, 2021
3246567
conflicts resolved back to upstream
Feb 4, 2022
a018d4d
Merge remote-tracking branch 'upstream/master'
Feb 15, 2022
15a37d0
Merge remote-tracking branch 'upstream/master'
Feb 17, 2022
892fa45
this is the spot
Feb 18, 2022
211013c
Merge remote-tracking branch 'upstream/master'
Feb 25, 2022
68104ee
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts Mar 9, 2022
d715a08
Merge remote-tracking branch 'upstream/master'
Mar 16, 2022
3565522
Merge remote-tracking branch 'upstream/master'
Mar 23, 2022
72e7b53
Merge remote-tracking branch 'upstream/master'
Mar 29, 2022
593872a
Merge remote-tracking branch 'upstream/master'
trishorts Apr 13, 2022
42dd034
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts Apr 13, 2022
fbeaec0
Merge remote-tracking branch 'upstream/master'
trishorts Jun 1, 2022
614ded7
Merge remote-tracking branch 'upstream/master'
Jun 14, 2022
47307c8
Merge branch 'master' of https://github.com/trishorts/mzLib
Jun 14, 2022
28e05ae
Merge remote-tracking branch 'upstream/master'
Jul 6, 2022
0a7c609
Merge remote-tracking branch 'upstream/master'
Jul 26, 2022
630d8c7
Merge remote-tracking branch 'upstream/master'
trishorts Jul 27, 2022
f6a386b
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts Jul 27, 2022
d673800
Merge remote-tracking branch 'upstream/master'
Sep 11, 2022
675a0ae
Merge branch 'master' of https://github.com/trishorts/mzLib
Sep 11, 2022
15d4baf
Merge remote-tracking branch 'upstream/master'
Sep 27, 2022
03ca9f7
Merge remote-tracking branch 'upstream/master'
Oct 4, 2022
d0a4c79
Merge remote-tracking branch 'upstream/master'
Jan 30, 2023
894b998
Merge remote-tracking branch 'upstream/master'
Mar 15, 2023
88269a1
Merge remote-tracking branch 'upstream/master'
trishorts Apr 24, 2023
9a9b24a
Merge remote-tracking branch 'upstream/master'
trishorts Jun 29, 2023
b4ad231
add space
trishorts Jun 29, 2023
bc59b38
Merge remote-tracking branch 'upstream/master'
trishorts Oct 10, 2023
2981dc5
Merge remote-tracking branch 'upstream/master'
trishorts Dec 12, 2023
898115d
addeed pride retriever class to useful proteomics databases
trishorts Jan 3, 2024
a45f9c8
Merge branch 'master' into proteomicsRepositoryRetriever
Alexander-Sol Jan 3, 2024
0b07a9e
small example downloads from pride
trishorts Jan 3, 2024
ca59d04
Merge branch 'proteomicsRepositoryRetriever' of https://github.com/tr…
trishorts Jan 3, 2024
9ec70ef
add ftp procedure
trishorts Jan 3, 2024
5ed7433
][o
trishorts Jan 3, 2024
5716557
simple web client download works
trishorts Jan 3, 2024
9b7311f
bunch of stuff that doesnt work
trishorts Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions mzLib/Test/TestPrideProjectRetriever.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UsefulProteomicsDatabases;
using NUnit.Framework;

namespace Test
{
[TestFixture]
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public class TestPrideProjectRetriever
{
[Test]
public void TestProjectRetrieve()
{
string projectAccession = "PXD048176";
string outputFullFilePath = @"E:\junk\junk.txt";

//UP000008595 is Uukuniemi virus (strain S23) (Uuk) which only has 4 proteins
string returnedFilePath = PrideRetriever.RetrieveMassSpecProject("", outputFullFilePath);

Assert.AreEqual(outputFullFilePath, returnedFilePath);
}
[Test]
public void TestRetrieveProjectFileByName()
{
string projectAccession = "PXD048176";
string filename = "d_atg1_d_atg11_proteome_data_analysis.7z";
string outputDirectory = @"E:\junk";

//UP000008595 is Uukuniemi virus (strain S23) (Uuk) which only has 4 proteins
string returnedFilePath = PrideRetriever.RetrieveProjectFileByFilename(projectAccession,filename, outputDirectory);

Assert.AreEqual(outputDirectory, returnedFilePath);
}
[Test]
public void TestRetrieveProjectFileListByProjectAccession()
{
string projectAccession = "PXD048176";
string outputDirectory = @"E:\junk";

//UP000008595 is Uukuniemi virus (strain S23) (Uuk) which only has 4 proteins
string returnedFilePath = PrideRetriever.RetrieveProjectFileListByProjectAccession(projectAccession, outputDirectory);

Assert.AreEqual(outputDirectory, returnedFilePath);
}
[Test]
public void TestPrideFtp()
{
PrideRetriever.PrideFtp();
}

[Test]
public void TestSimpleWebClientDownload()
{
string uri = "ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2023/12/PXD048176/d_atg1_d_atg11_proteome_data_analysis.7z";
string fullFilePath = @"E:\junk\PXD048176\d_atg1_d_atg11_proteome_data_analysis.7z";
PrideRetriever.SimpleWebClientDownload(uri,fullFilePath);
}

[Test]
public void DownloadUniProtProteomes()
{
var j = ProteinDbRetriever.DownloadAvailableUniProtProteomes(@"E:\junk");
}
}
}
88 changes: 88 additions & 0 deletions mzLib/UsefulProteomicsDatabases/PrideRetriever.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Easy.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace UsefulProteomicsDatabases
{
public class PrideRetriever
{
private string b = "https://www.ebi.ac.uk/pride/ws/archive/v2/status/PXD048177";


public static string RetrieveMassSpecProject(string PrideProjectAccession, string outputFullFilePath)
{
string htmlQueryString = "https://www.ebi.ac.uk/pride/ws/archive/v2/status/" + PrideProjectAccession;

if (htmlQueryString.Length > 0)
{
Loaders.DownloadContent(htmlQueryString, outputFullFilePath);
return outputFullFilePath;
}

return "";
}
public static string RetrieveProjectFileByFilename(string prideProjectAccession, string prideFilename, string outputFileDirectory)
{
string htmlQueryString =
"https://www.ebi.ac.uk/pride/ws/archive/v2/files/fileByName?fileName=" + prideFilename + "&projectAccession=" + prideProjectAccession;

if (htmlQueryString.Length > 0)
{
Loaders.DownloadContent(htmlQueryString, Path.Join(outputFileDirectory,prideFilename));
return outputFileDirectory;
}

return "";
}
public static string RetrieveProjectFileListByProjectAccession(string prideProjectAccession, string outputFileDirectory)
{
string htmlQueryString =
"https://www.ebi.ac.uk/pride/private/ws/archive/v2/" + "projects/" + prideProjectAccession + "/files";

if (htmlQueryString.Length > 0)
{
Loaders.DownloadContent(htmlQueryString, Path.Join(outputFileDirectory, prideProjectAccession + ".json"));
return outputFileDirectory;
}

return "";
}
public static void PrideFtp()
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2023/12/PXD048176/d_atg1_d_atg11_proteome_data_analysis.7z");
request.Method = WebRequestMethods.Ftp.DownloadFile;

// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("anonymous", "anonymous");

request.KeepAlive = true;
request.UsePassive = true;
request.UseBinary = true;

//// Read the file from the server & write to destination
//using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) // Error here
//using (Stream responseStream = response.GetResponseStream())
//using (StreamReader reader = new StreamReader(responseStream))
//using (StreamWriter destination = new StreamWriter(destinationFile))
//{
// destination.Write(reader.ReadToEnd());
// destination.Flush();
//}

}

public static void SimpleWebClientDownload(string url, string fullFilePath)
{
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("anonymous", "anonymous");
client.DownloadFile(
url, fullFilePath);
}
}
}
Loading