If you know there could be and error use try
if it is in a loop and you need to keep going, next!
m <- try(read.table(f, head=FALSE, sep="\t"))
if(class(m) == "try-error") next
Thursday, May 9, 2013
compare two files! #shell
Excellent!
#in file 1 but not in file 2
diff --changed-group-format='%<' --unchanged-group-format='' file1 file2 > output
#in file 2 but not in file 1
diff --changed-group-format='%>' --unchanged-group-format='' file1 file2 > output
#Common in both files
diff --changed-group-format='' --unchanged-group-format='%=' file1 file2 > output
From -> linux questions
#in file 1 but not in file 2
diff --changed-group-format='%<' --unchanged-group-format='' file1 file2 > output
#in file 2 but not in file 1
diff --changed-group-format='%>' --unchanged-group-format='' file1 file2 > output
#Common in both files
diff --changed-group-format='' --unchanged-group-format='%=' file1 file2 > output
From -> linux questions
Wednesday, May 8, 2013
Tuesday, May 7, 2013
substring in list #python
if any("abc" in s for s in some_list):
# whatever
to get all the items containing "abc", usematching = [s for s in some_list if "abc" in s]
http://stackoverflow.com/questions/4843158/check-in-python-if-a-list-item-contains-a-string
extract a group of fasta sequences from a file
extract a group of fasta sequences from a file
in python
http://www.biostars.org/p/1709/
in python
http://www.biostars.org/p/1709/
from Bio import SeqIO
fasta_file = "fasta_file.fasta" # Input fasta file
wanted_file = "wanted_file.txt" # Input interesting sequence IDs, one per line
result_file = "result_file.fasta" # Output fasta file
wanted = set()
with open(wanted_file) as f:
for line in f:
line = line.strip()
if line != "":
wanted.add(line)
fasta_sequences = SeqIO.parse(open(fasta_file),'fasta')
with open(result_file, "w") as f:
for seq in fasta_sequences:
if seq.id in wanted:
SeqIO.write([seq], f, "fasta")
grep OR AND etc
OR
grep -E 'pattern1|pattern2' filename
AND
grep -E 'pattern1.*pattern2' filename
http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
UniProtKB/Swiss-Prot
UniprotKB Protein knowledgebase, consists of two sections:
UniProtKB/Swiss-Prot is the manually annotated and reviewed section of the UniProt Knowledgebase (UniProtKB).
documentation
Downloads > http://www.uniprot.org/downloads
Swiss-Prot, which is manually annotated and reviewed.
TrEMBL, which is automatically annotated and is not reviewed.
UniProtKB/Swiss-Prot is the manually annotated and reviewed section of the UniProt Knowledgebase (UniProtKB).
documentation
Downloads > http://www.uniprot.org/downloads
UniProt Knowledgebase (UniProtKB) Release 2013_05 (01-May-2013)
UniProtKB/Swiss-Prot: 540,052 entries
release notes 1st of May 2013 >
ftp://ftp.uniprot.org/pub/databases/uniprot/relnotes.txt
http://web.expasy.org/docs/relnotes/relstat.html
unmodified files, untouched #shell
find ./ -type f -atime +90
grep in loop # shell
In one line
for f in *.excov; do echo "file $f "; grep -c 'false' $f; done > lostgenes.txt
for f in *.excov; do echo "file $f "; grep -c 'false' $f; done > lostgenes.txt
Monday, May 6, 2013
split one column into two by a string #R
library(stringr)
str_split_fixed(column, "string", 2)
Friday, May 3, 2013
call R files from shell
module load R
R --no-save < file.R
R --no-save < file.R
Sum matrices from a list #R
Mergefiles <- function(FOL, listM){
path <- getwd()
setwd(FOL)
print(length(listM))
newmatrix <- Reduce('+', listM)
#add first column names
newmatrix[,1]<- names(newmatrix)[-1]
#write file
write.table(newmatrix,file="mergedmatrixXA.txt",sep="\t", row.names=FALSE, quote=FALSE)
setwd(path)
}
path <- getwd()
setwd(FOL)
print(length(listM))
newmatrix <- Reduce('+', listM)
#add first column names
newmatrix[,1]<- names(newmatrix)[-1]
#write file
write.table(newmatrix,file="mergedmatrixXA.txt",sep="\t", row.names=FALSE, quote=FALSE)
setwd(path)
}
Thursday, May 2, 2013
UniProt Go
UniProt GOA (Uniprot GO Annotation)
http://www.ebi.ac.uk/GOA
Readme file
UniProt (Swiss-Prot and TrEMBL)
ftp://ftp.geneontology.org/.../gene_association.goa_uniprot.gz ftp://ftp.ebi.ac.uk/.../gene_association.goa_uniprot.gz
This file contains all GO annotations for proteins in the UniProt KnowledgeBase (UniProtKB).
Read me file ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/UNIPROT/gp_association_readme
17 columns
ftp://ftp.geneontology.org/.../gene_association.goa_arabidopsis.gz ftp://ftp.ebi.ac.uk/.../gene_association.goa_arabidopsis.gz
This file contains the GO assignments for the proteins of the arabidopsis UniProtKB Complete
Proteome.
Read me file ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/ARABIDOPSIS/README
might search for individual IDs in the uniref90DB
http://www.ebi.ac.uk/ebisearch/search.ebi?db=uniref90&t=B9DGW5
I might check Arabiposis annotation from TAIR10
ftp://ftp.arabidopsis.org/home/tair/Ontologies/Gene_Ontology/ATH_GO_GOSLIM.txt
http://www.ebi.ac.uk/GOA
Readme file
UniProt (Swiss-Prot and TrEMBL)
gene_association.goa_uniprot
Locations:ftp://ftp.geneontology.org/.../gene_association.goa_uniprot.gz ftp://ftp.ebi.ac.uk/.../gene_association.goa_uniprot.gz
This file contains all GO annotations for proteins in the UniProt KnowledgeBase (UniProtKB).
Read me file ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/UNIPROT/gp_association_readme
GAF 2.0 file format
colNames <- c("DB", "DB_Object_ID", "DB_Object_Symbol", "Qualifier", "GO_ID", "DB:Reference", "Evidence", "With", "Aspect", "DB_Object_Name", "Synonym", "DB_Object_Type", "Taxon_ID", "Date", "Assigned_By", "Annotation_Extension", "Gene_Product_Form_ID")17 columns
gene_association.goa_arabidopsis
Locations:ftp://ftp.geneontology.org/.../gene_association.goa_arabidopsis.gz ftp://ftp.ebi.ac.uk/.../gene_association.goa_arabidopsis.gz
This file contains the GO assignments for the proteins of the arabidopsis UniProtKB Complete
Proteome.
Read me file ftp://ftp.ebi.ac.uk/pub/databases/GO/goa/ARABIDOPSIS/README
Extras
might search for individual IDs in the uniref90DB
http://www.ebi.ac.uk/ebisearch/search.ebi?db=uniref90&t=B9DGW5
I might check Arabiposis annotation from TAIR10
ftp://ftp.arabidopsis.org/home/tair/Ontologies/Gene_Ontology/ATH_GO_GOSLIM.txt
Subscribe to:
Posts (Atom)